-
Notifications
You must be signed in to change notification settings - Fork 121
[POS Settings] Adjust settings Controller-Service interface and dependencies #16053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[POS Settings] Adjust settings Controller-Service interface and dependencies #16053
Conversation
Generated by 🚫 Danger |
|
|
PluginService in SettingsController. Clear protocol interface. Model for store details.| } | ||
|
|
||
| // Temporary: Simplified copy from PointOfSaleOrderListView.GhostOrderRowView | ||
| private struct GhostSettingRowView: View { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is a mere copy of existing GhostOrderRowView, where I removed one of the extra lines. I'll iterate on this when I do the final design iteration tomorrow/next week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just wondering, this is a separate UI enhancement from the architecture changes right? or does this become necessary after the refactoring? I'm not sure what the differences between these two structs, would be great to reuse the shared component if applicable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a separate UI enhancement from the architecture changes right? or does this become necessary after the refactoring?
That's separate from the architecture changes yes, just added it temporarily to reflect isLoading state changes in the UI. I'll be updating the struct in the next PR with the rest of UI updates 👍
jaclync
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the changes and unit tests, still working as expected
just some non-blocking comments.
| import enum Yosemite.Plugin | ||
| import struct Yosemite.SiteSetting | ||
|
|
||
| final class StoreSettingsViewModel: ObservableObject { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: on the first glance, I thought this is a class from store management. Maybe the prefix could be added for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah! Updated 037c47d
| viewModel: StoreSettingsViewModel(siteID: settingsController.siteID, | ||
| settingsService: settingsController.settingsService, | ||
| pluginsService: settingsController.pluginsService)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: with the current implementation, the view model isn't owned by any class and just initialized whenever this view is redrawn. Do we want the settings controller to own this view model, like if we want to keep the already retrieved receipt settings? This way, these 3 dependenceis (siteID, settingsService, pluginsService) don't have to be public either.
| struct PointOfSaleSettingsStoreDetailView: View { | ||
| @State private var isLoading: Bool = false | ||
|
|
||
| let settingsController: PointOfSaleSettingsControllerProtocol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it looks like settingsController is now only needed for storeName and storeAddress. Could these two values be provided by the view model, if no other settings sections need these info? so that the view only relies on the view model, leaving settings controller for keeping global states?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very true, updated: 3af72b4
| } | ||
|
|
||
| // Temporary: Simplified copy from PointOfSaleOrderListView.GhostOrderRowView | ||
| private struct GhostSettingRowView: View { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just wondering, this is a separate UI enhancement from the architecture changes right? or does this become necessary after the refactoring? I'm not sure what the differences between these two structs, would be great to reuse the shared component if applicable.
| receiptInformation = POSReceiptInformation( | ||
| storeName: settingValue(from: siteSettings, settingID: "woocommerce_pos_store_name"), | ||
| storeAddress: settingValue(from: siteSettings, settingID: "woocommerce_pos_store_address"), | ||
| phone: settingValue(from: siteSettings, settingID: "woocommerce_pos_store_phone"), | ||
| email: settingValue(from: siteSettings, settingID: "woocommerce_pos_store_email"), | ||
| refundReturnsPolicy: settingValue(from: siteSettings, settingID: "woocommerce_pos_refund_returns_policy") | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: how about moving the setting value mapping to settingsService.retrievePointOfSaleSettings for these fields in Yosemite, so that the method returns POSReceiptInformation? If there are more than receipt settings in the settings from this method, POSReceiptInformation can be included in a new struct as the return type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, at the moment is only receipt info, but I can foresee we'll have more pretty soon. Moved to Yosemite and updated: 951d0ad
| #expect(sut.shouldShowReceiptInformation == false) | ||
| } | ||
|
|
||
| @Test func retrievePOSReceiptSettings_when_no_plugin_then_shouldShowReceiptInformation_returns_false() async throws { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice test cases for different plugin states 👍

Closes WOOMOB-1176
Closes WOOMOB-1188
Closes WOOMOB-1205
Description
This PR adjusts and cleans up the responsibilities of the
PointOfSaleSettingsControllerby:settingsServiceandpluginsServiceinto thesettingsControllersiteIDfrom the protocolI've also added a temporary "ghost table" for the loading state:
Screen.Recording.2025-08-28.at.20.43.46.mov
Testing